<?php
include_only();

$user_info = get_user_info();
$user_id = $user_info['id'];
//print_r($user_info);

if(!empty($save_email) and $save_email=='yes')
{
mysql_query("UPDATE `users` SET `email` = '$email' WHERE `id` = '$user_id' LIMIT 1 ;");
}

if(!empty($save_password) and $save_password=='yes')
{
if(sha1($old_password)==$user_info['password'])
{
if($new_password == $confirm_new_password)
{
$encrypted_password = sha1($new_password);
mysql_query("UPDATE `users` SET `password` = '$encrypted_password' WHERE `id` = '$user_id' LIMIT 1 ;");
}
}
}


//to get new data after change

$user_info = get_user_info();

$control_panel = "
<form method='post' action='index.php'>
<b>change email address: </b><br>
<table>
<tr>
<td>email address:</td>
<td>
<input type='text' name='email' value='".$user_info['email']."' />
<input type='hidden' name='page' value='ucp' />
<input type='hidden' name='save_email' value='yes' />
<input type='submit' value='change email' />
</td>
</tr>
</table>
</form>
";

$control_panel = $control_panel . "
<br><br>
<form method='post' action='index.php'>
<b>change password:</b>
<table>
<tr>
<td>old password: </td>
<td><input type='password' name='old_password' /></td>
</tr>
<tr>
<td>new password: </td>
<td><input type='password' name='new_password' /></td>
</tr>
<tr>
<td>confirm new password: </td>
<td><input type='password' name='confirm_new_password' /></td>
</tr>
</table>
<input type='hidden' name='page' value='ucp' />
<input type='hidden' name='save_password' value='yes' />
<input type='submit' value='change password' />
</form>
";
?>










